﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Collections;
using ThanhTu.GNC.Media.KQXS.DataAccess.DAL;
using ThanhTu.GNC.Media.KQXS.DataAccess.DO;

namespace WebUI.Admin.UserControls
{
    public partial class ActionSyntax : System.Web.UI.UserControl
    {
        public int UserListCount { get; set; }
        int rowCount = 0;
        int pageIndex =1;
        int pageSize=10;
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                pageIndex = int.Parse(Request.QueryString["[p"].ToString());
            }
            catch { }
            if (!IsPostBack)
            {
                MessengerSyntaxDAL messengerSyntaxDAL = new MessengerSyntaxDAL();
                DataTable dt = messengerSyntaxDAL.SelectAll_Messenger(pageIndex, pageSize, ref rowCount);
                RepeaterSyntax.DataSource = dt;
                RepeaterSyntax.DataBind();
                NHPagingControl1.TotalPage = (rowCount % pageSize == 0) ? rowCount / pageSize : rowCount / pageSize + 1;
               
            }
        }

        protected void RepeaterSyntax_mmand(object source, RepeaterCommandEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                MessengerSyntaxDAL messengerSyntax = new MessengerSyntaxDAL();
                int checkDel = messengerSyntax.delete(e.CommandName,e.CommandArgument.ToString());
                if (checkDel > 0)
                {
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "ShowStatus", "javascript:alert('XÓA CÚ PHÁP Tin Nhắn Thành công);", true);
                }
                else
                {
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "ShowStatus", "javascript:alert('LỖICXÓA CÚ PHÁP ,XIN VUI LÒNG THỬ LẠI);", true);
                }
            }

        }

        
    }
}